package com.hippo.javacore.javaiostream.iostream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

/**
 * @ClassName PrintStreamOrWriterApplication
 * @Description TODO 打印流的应用
 * @Author tangxl
 * @create 2023-04-07 09:29
 **/
public class PrintStreamOrWriterApplication {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        System.out.println("Java开发技术高，");
        System.out.println("编程语言普及广。");
        System.out.println("代码简洁易懂懂，");
        System.out.println("面向对象优点多。");
        System.out.println("Java程序员辛勤，");
        System.out.println("工作细致又周到。");
        try(
                // 1.创建打印流管道
                PrintStream ps = new PrintStream(new FileOutputStream("study-commons/java-file-iostream/src/main/resources/file/a.txt",true),true,"UTF-8");
                ) {
            // 修改系统打印流，可以将数据输出到指定的文件中
            System.setOut(ps);
            System.out.println("每日写代码累累，");
            System.out.println("但是收获也颇多。");
            System.out.println("先进的编程语言，");
            System.out.println("强大的框架体系。");
            System.out.println("Java程序员智慧，");
            System.out.println("编程技术日益增。");
            System.out.println("开发效率高又快，");
            System.out.println("代码质量优质。");
            System.out.println("Java程序员专业，");
            System.out.println("技术实力必然强。");

        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
